<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Category extends MX_Controller {


	function __construct(){

		$this->load->model('category/category_model');
		$this->load->library('currency/currency');
	}
	
	function lists($category_id){
				
		$data['cat'] = $this->category_model->get_category($category_id);
		
		if($data['cat'] == NULL){
			$this->load->view('category/category_not_found');	
		}else{
		
			$offset = $this->uri->segment(4);
			$limit = '5';
			if(!$offset){
				$page = 0;
			}else{
				$page = $offset; 	
			}
			
			
			$data['product'] = $this->category_model->get_list_product($category_id, $page, $limit);
			
			
			
			$config_pagination['base_url']    = site_url('category/lists/'.$category_id);
			$config_pagination['total_rows']  = count($this->category_model->get_list_product($category_id, 0, 0));
			$config_pagination['per_page']    = $limit;
			$config_pagination['uri_segment'] = 4;
			$config_pagination['num_links']   = 4;
	
			//pagination style
			$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
			$config_pagination['full_tag_close'] = '</ul></div>';
	
			$config_pagination['first_link'] = 'First';
			$config_pagination['first_tag_open']  = '<li>';
			$config_pagination['first_tag_close'] = '</li>';
	
			$config_pagination['last_link'] = 'Last';
			$config_pagination['last_tag_open']  = '<li>';
			$config_pagination['last_tag_close'] = '</li>';
	
			$config_pagination['next_link'] = '&gt;';
			$config_pagination['next_tag_open']  = '<li>';
			$config_pagination['next_tag_close'] = '</li>';
	
			$config_pagination['prev_link'] = '&lt;';
			$config_pagination['prev_tag_open'] = '<li>';
			$config_pagination['prev_tag_close'] = '</li>';
	
			$config_pagination['cur_tag_open'] = '<li><span class="current">';
			$config_pagination['cur_tag_close'] = '</span></li>';
	
			$config_pagination['num_tag_open'] = '<li>';
			$config_pagination['num_tag_close'] = '</li>';
	
			$this->pagination->initialize($config_pagination); 
			$data['pagination'] = $this->pagination->create_links();
			
			$this->load->view('category/category',$data);
		}
	}
	
	function grid($category_id){
		
		$data['cat'] = $this->category_model->get_category($category_id);
		
		if($data['cat'] == NULL){
			$this->load->view('category/category_not_found');	
		}else{
		
			$offset = $this->uri->segment(4);
			$limit = '12';
			if(!$offset){
				$page = 0;
			}else{
				$page = $offset; 	
			}
			
			$data['product'] = $this->category_model->get_list_product($category_id, $page, $limit);
			
			$config_pagination['base_url']    = site_url('category/grid/'.$category_id);
			$config_pagination['total_rows']  = count($this->category_model->get_list_product($category_id, 0, 0));
			$config_pagination['per_page']    = $limit;
			$config_pagination['uri_segment'] = 4;
			$config_pagination['num_links']   = 4;
	
			//pagination style
			$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
			$config_pagination['full_tag_close'] = '</ul></div>';
	
			$config_pagination['first_link'] = 'First';
			$config_pagination['first_tag_open']  = '<li>';
			$config_pagination['first_tag_close'] = '</li>';
	
			$config_pagination['last_link'] = 'Last';
			$config_pagination['last_tag_open']  = '<li>';
			$config_pagination['last_tag_close'] = '</li>';
	
			$config_pagination['next_link'] = '&gt;';
			$config_pagination['next_tag_open']  = '<li>';
			$config_pagination['next_tag_close'] = '</li>';
	
			$config_pagination['prev_link'] = '&lt;';
			$config_pagination['prev_tag_open'] = '<li>';
			$config_pagination['prev_tag_close'] = '</li>';
	
			$config_pagination['cur_tag_open'] = '<li><span class="current">';
			$config_pagination['cur_tag_close'] = '</span></li>';
	
			$config_pagination['num_tag_open'] = '<li>';
			$config_pagination['num_tag_close'] = '</li>';
	
			$this->pagination->initialize($config_pagination); 
			$data['pagination'] = $this->pagination->create_links();
			$this->load->view('category/category_grid',$data);
		}
	}
	
	function lists_low($category_id){
		
		$data['cat'] = $this->category_model->get_category($category_id);
		
		if($data['cat'] == NULL){
			$this->load->view('category/category_not_found');	
		}else{
		
			$offset = $this->uri->segment(4);
			$limit = '5';
			if(!$offset){
				$page = 0;
			}else{
				$page = $offset; 	
			}
			
			
			$data['product'] = $this->category_model->get_list_product_low($category_id, $page, $limit);
			
			$config_pagination['base_url']    = site_url('category/lists_low/'.$category_id);
			$config_pagination['total_rows']  = count($this->category_model->get_list_product_low($category_id, 0, 0));
			$config_pagination['per_page']    = $limit;
			$config_pagination['uri_segment'] = 4;
			$config_pagination['num_links']   = 4;
	
			//pagination style
			$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
			$config_pagination['full_tag_close'] = '</ul></div>';
	
			$config_pagination['first_link'] = 'First';
			$config_pagination['first_tag_open']  = '<li>';
			$config_pagination['first_tag_close'] = '</li>';
	
			$config_pagination['last_link'] = 'Last';
			$config_pagination['last_tag_open']  = '<li>';
			$config_pagination['last_tag_close'] = '</li>';
	
			$config_pagination['next_link'] = '&gt;';
			$config_pagination['next_tag_open']  = '<li>';
			$config_pagination['next_tag_close'] = '</li>';
	
			$config_pagination['prev_link'] = '&lt;';
			$config_pagination['prev_tag_open'] = '<li>';
			$config_pagination['prev_tag_close'] = '</li>';
	
			$config_pagination['cur_tag_open'] = '<li><span class="current">';
			$config_pagination['cur_tag_close'] = '</span></li>';
	
			$config_pagination['num_tag_open'] = '<li>';
			$config_pagination['num_tag_close'] = '</li>';
	
			$this->pagination->initialize($config_pagination); 
			$data['pagination'] = $this->pagination->create_links();
			
			$this->load->view('category/category_low',$data);
		}
	}
	
	function grid_low($category_id){
		
		$data['cat'] = $this->category_model->get_category($category_id);
		
		if($data['cat'] == NULL){
			$this->load->view('category/category_not_found');	
		}else{
		
			$offset = $this->uri->segment(4);
			$limit = '12';
			if(!$offset){
				$page = 0;
			}else{
				$page = $offset; 	
			}
			
			$data['product'] = $this->category_model->get_list_product_low($category_id, $page, $limit);
			
			$config_pagination['base_url']    = site_url('category/grid_low/'.$category_id);
			$config_pagination['total_rows']  = count($this->category_model->get_list_product_low($category_id, 0, 0));
			$config_pagination['per_page']    = $limit;
			$config_pagination['uri_segment'] = 4;
			$config_pagination['num_links']   = 4;
	
			//pagination style
			$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
			$config_pagination['full_tag_close'] = '</ul></div>';
	
			$config_pagination['first_link'] = 'First';
			$config_pagination['first_tag_open']  = '<li>';
			$config_pagination['first_tag_close'] = '</li>';
	
			$config_pagination['last_link'] = 'Last';
			$config_pagination['last_tag_open']  = '<li>';
			$config_pagination['last_tag_close'] = '</li>';
	
			$config_pagination['next_link'] = '&gt;';
			$config_pagination['next_tag_open']  = '<li>';
			$config_pagination['next_tag_close'] = '</li>';
	
			$config_pagination['prev_link'] = '&lt;';
			$config_pagination['prev_tag_open'] = '<li>';
			$config_pagination['prev_tag_close'] = '</li>';
	
			$config_pagination['cur_tag_open'] = '<li><span class="current">';
			$config_pagination['cur_tag_close'] = '</span></li>';
	
			$config_pagination['num_tag_open'] = '<li>';
			$config_pagination['num_tag_close'] = '</li>';
	
			$this->pagination->initialize($config_pagination); 
			$data['pagination'] = $this->pagination->create_links();
			$this->load->view('category/category_grid_low',$data);
		}
	}
	
	function lists_high($category_id){
		
		$data['cat'] = $this->category_model->get_category($category_id);
		
		if($data['cat'] == NULL){
			$this->load->view('category/category_not_found');	
		}else{
		
			$offset = $this->uri->segment(4);
			$limit = '5';
			if(!$offset){
				$page = 0;
			}else{
				$page = $offset; 	
			}
			
			
			$data['product'] = $this->category_model->get_list_product_high($category_id, $page, $limit);
			
			$config_pagination['base_url']    = site_url('category/lists_high/'.$category_id);
			$config_pagination['total_rows']  = count($this->category_model->get_list_product_high($category_id, 0, 0));
			$config_pagination['per_page']    = $limit;
			$config_pagination['uri_segment'] = 4;
			$config_pagination['num_links']   = 4;
	
			//pagination style
			$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
			$config_pagination['full_tag_close'] = '</ul></div>';
	
			$config_pagination['first_link'] = 'First';
			$config_pagination['first_tag_open']  = '<li>';
			$config_pagination['first_tag_close'] = '</li>';
	
			$config_pagination['last_link'] = 'Last';
			$config_pagination['last_tag_open']  = '<li>';
			$config_pagination['last_tag_close'] = '</li>';
	
			$config_pagination['next_link'] = '&gt;';
			$config_pagination['next_tag_open']  = '<li>';
			$config_pagination['next_tag_close'] = '</li>';
	
			$config_pagination['prev_link'] = '&lt;';
			$config_pagination['prev_tag_open'] = '<li>';
			$config_pagination['prev_tag_close'] = '</li>';
	
			$config_pagination['cur_tag_open'] = '<li><span class="current">';
			$config_pagination['cur_tag_close'] = '</span></li>';
	
			$config_pagination['num_tag_open'] = '<li>';
			$config_pagination['num_tag_close'] = '</li>';
	
			$this->pagination->initialize($config_pagination); 
			$data['pagination'] = $this->pagination->create_links();
			
			$this->load->view('category/category_high',$data);
		}
	}
	
	function grid_high($category_id){
		
		$data['cat'] = $this->category_model->get_category($category_id);
		
		if($data['cat'] == NULL){
			$this->load->view('category/category_not_found');	
		}else{
		
			$offset = $this->uri->segment(4);
			$limit = '12';
			if(!$offset){
				$page = 0;
			}else{
				$page = $offset; 	
			}
			
			$data['product'] = $this->category_model->get_list_product_high($category_id, $page, $limit);
			
			$config_pagination['base_url']    = site_url('category/grid_high/'.$category_id);
			$config_pagination['total_rows']  = count($this->category_model->get_list_product_high($category_id, 0, 0));
			$config_pagination['per_page']    = $limit;
			$config_pagination['uri_segment'] = 4;
			$config_pagination['num_links']   = 4;
	
			//pagination style
			$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
			$config_pagination['full_tag_close'] = '</ul></div>';
	
			$config_pagination['first_link'] = 'First';
			$config_pagination['first_tag_open']  = '<li>';
			$config_pagination['first_tag_close'] = '</li>';
	
			$config_pagination['last_link'] = 'Last';
			$config_pagination['last_tag_open']  = '<li>';
			$config_pagination['last_tag_close'] = '</li>';
	
			$config_pagination['next_link'] = '&gt;';
			$config_pagination['next_tag_open']  = '<li>';
			$config_pagination['next_tag_close'] = '</li>';
	
			$config_pagination['prev_link'] = '&lt;';
			$config_pagination['prev_tag_open'] = '<li>';
			$config_pagination['prev_tag_close'] = '</li>';
	
			$config_pagination['cur_tag_open'] = '<li><span class="current">';
			$config_pagination['cur_tag_close'] = '</span></li>';
	
			$config_pagination['num_tag_open'] = '<li>';
			$config_pagination['num_tag_close'] = '</li>';
	
			$this->pagination->initialize($config_pagination); 
			$data['pagination'] = $this->pagination->create_links();
			$this->load->view('category/category_grid_high',$data);
		}
	}
	
}

/* End of file common.php */